import http from '@ohos.net.http';
import router from '@system.router';
export default {
    data: {
        image1src:"/common/login/login1.png",
        image2src:"/common/login/login2.png",
        image3src:"/common/login/login3.png",
        title: 'World',
        sit:0,
        username:0,
    },
    tuichu(){
        router.back();
    },
    imageonclick(){
        if(this.sit==0){
            this.sit=1;
            this.image3src = "/common/login/login4.png";
        }
        else{
            this.sit=0;
            this.image3src = "/common/login/login3.png";
        }
    },
    register(){
        if(this.sit==1){
            let httpRequest = http.createHttp();
            httpRequest.request(this.$app.$def.globalData.baseURL + "/register", {
                method: 'POST',
                header: {
                    'Content-Type': 'application/json'
                },
                extraData: {
                    "username": "123",
                    "password": "123"
                }
            }, (err, data) => {
                if (!err) {
                    console.info('Result:' + data.result);
                    if (data.result == 0) {
                        router.push({
                            uri: 'pages/login/login',
                            params: {
                                username: this.username
                            }
                        })
                    } else {
                        console.log("账户名或密码错误" + this.rpassword + this.rusername);
                        this.$element('dragDialog').show();
                    }
                } else {
                    console.log('error:' + err.data);
                }
            });
        }
        else{
            this.$element("dragDialog1").show();
        }
    },
    change(e){
        this.username = e.value;
    },
    setSchedule1(){
        this.$element("dragDialog1").close();
    }
}
